﻿using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using HelloWorld.ViewModels.Home;

namespace HelloWorld.Repositories
{
    public class MenuRepository : IMenuRepository
    {
        readonly List<MenuItem> items;

        public MenuRepository()
        {
            items = new List<MenuItem>
                    {
                        new MenuItem { Id = 1, Text = "Item 1"},
                        new MenuItem { Id = 2, Text = "Item 2"},
                        new MenuItem { Id = 3, Parent = 1, Text = "Item 3", IsLeaf = true, ControllerAction = "MenuTargets.Item3"},
                        new MenuItem { Id = 4, Parent = 1, Text = "Item 4"},
                        new MenuItem { Id = 5, Parent = 2, Text = "Item 5", IsLeaf = true, ControllerAction = "MenuTargets.Item5"},
                        new MenuItem { Id = 6, Parent = 4, Text = "Item 6", IsLeaf = true, ControllerAction = "MenuTargets.Item6" }
                    };
        }

        public ObservableCollection<MenuItem> GetItems()
        {
            return new ObservableCollection<MenuItem>(items.Where(i=>i.Parent == null));
        }

        public ObservableCollection<MenuItem> GetItems(MenuItem item)
        {
            return new ObservableCollection<MenuItem>(items.Where(i => i.Parent == item.Id));            
        }
    }
}